
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>2.2 启动 & 打包 · 文档中心</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Joe Chan">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-accordion/accordion.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-yahei/yahei.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-fexa/fexa.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="2.3 配置.html" />
    
    
    <link rel="prev" href="2.1 安装.html" />
    

    </head>
    <body>
        
<div class="book">
	<div class="header-inner">
		<!-- LOGO -->
		<div class="logo"></div>
		<span class="title"></span>

		<!-- Search -->
		
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>


		<!-- Nav -->
		<ul class="header-nav">
			
		</ul>
	</div>

	<div class="book-summary">
		<div class="book-summary-title">文档目录</div>
		
		
		<nav role="navigation">
			


<ul class="summary">
    
    

    

    
        
        <li class="header">Csingo</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    1 前言
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../1 前言/1.1 项目介绍.html">
            
                <a href="../1 前言/1.1 项目介绍.html">
            
                    
                    1.1 项目介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../1 前言/1.2 编程须知.html">
            
                <a href="../1 前言/1.2 编程须知.html">
            
                    
                    1.2 编程须知
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../1 前言/1.3 性能压测.html">
            
                <a href="../1 前言/1.3 性能压测.html">
            
                    
                    1.3 性能压测
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../1 前言/1.4 版本更新.html">
            
                <a href="../1 前言/1.4 版本更新.html">
            
                    
                    1.4 版本更新
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    2 快速入门
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="2.1 安装.html">
            
                <a href="2.1 安装.html">
            
                    
                    2.1 安装
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.2" data-path="2.2 启动 & 打包.html">
            
                <a href="2.2 启动 & 打包.html">
            
                    
                    2.2 启动 & 打包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="2.3 配置.html">
            
                <a href="2.3 配置.html">
            
                    
                    2.3 配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="2.4 容器.html">
            
                <a href="2.4 容器.html">
            
                    
                    2.4 容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="2.5 依赖注入.html">
            
                <a href="2.5 依赖注入.html">
            
                    
                    2.5 依赖注入
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="2.6 协程上下文.html">
            
                <a href="2.6 协程上下文.html">
            
                    
                    2.6 协程上下文
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="2.7 Proto使用技巧.html">
            
                <a href="2.7 Proto使用技巧.html">
            
                    
                    2.7 Proto使用技巧
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    3 基础功能
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../3 基础功能/3.1 路由.html">
            
                <a href="../3 基础功能/3.1 路由.html">
            
                    
                    3.1 路由
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../3 基础功能/3.2 控制器.html">
            
                <a href="../3 基础功能/3.2 控制器.html">
            
                    
                    3.2 控制器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../3 基础功能/3.3 验证器.html">
            
                <a href="../3 基础功能/3.3 验证器.html">
            
                    
                    3.3 验证器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../3 基础功能/3.4 中间件.html">
            
                <a href="../3 基础功能/3.4 中间件.html">
            
                    
                    3.4 中间件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../3 基础功能/3.5 应用服务.html">
            
                <a href="../3 基础功能/3.5 应用服务.html">
            
                    
                    3.5 应用服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../3 基础功能/3.6 领域服务.html">
            
                <a href="../3 基础功能/3.6 领域服务.html">
            
                    
                    3.6 领域服务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../3 基础功能/3.7 模型.html">
            
                <a href="../3 基础功能/3.7 模型.html">
            
                    
                    3.7 模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../3 基础功能/3.8 任务命令.html">
            
                <a href="../3 基础功能/3.8 任务命令.html">
            
                    
                    3.8 任务命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../3 基础功能/3.9 请求.html">
            
                <a href="../3 基础功能/3.9 请求.html">
            
                    
                    3.9 请求
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../3 基础功能/3.10 响应.html">
            
                <a href="../3 基础功能/3.10 响应.html">
            
                    
                    3.10 响应
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.11" data-path="../3 基础功能/3.11 异常.html">
            
                <a href="../3 基础功能/3.11 异常.html">
            
                    
                    3.11 异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.12" data-path="../3 基础功能/3.12 日志.html">
            
                <a href="../3 基础功能/3.12 日志.html">
            
                    
                    3.12 日志
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    4 组件库
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../4 组件库/4.1 配置中心.html">
            
                <a href="../4 组件库/4.1 配置中心.html">
            
                    
                    4.1 配置中心
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../4 组件库/4.2 Proto.html">
            
                <a href="../4 组件库/4.2 Proto.html">
            
                    
                    4.2 Proto
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../4 组件库/4.3 Redis.html">
            
                <a href="../4 组件库/4.3 Redis.html">
            
                    
                    4.3 Redis
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../4 组件库/4.4 Kafka.html">
            
                <a href="../4 组件库/4.4 Kafka.html">
            
                    
                    4.4 Kafka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../4 组件库/4.4 RabbitMQ.html">
            
                <a href="../4 组件库/4.4 RabbitMQ.html">
            
                    
                    4.4 RabbitMQ
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" >
            
                <span>
            
                    
                    5 微服务
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../5 微服务/5.1 HTTP-RPC.html">
            
                <a href="../5 微服务/5.1 HTTP-RPC.html">
            
                    
                    5.1 HTTP RPC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../5 微服务/5.2 应用SDK.html">
            
                <a href="../5 微服务/5.2 应用SDK.html">
            
                    
                    5.2 应用SDK
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


		</nav>
		
		
	</div>

	<!-- Content nav -->
	<div class="book-anchor">
		<div class="book-anchor-title">在这篇文章中:</div>
		<div class="book-anchor-body">

		</div>
	</div>

	<div class="book-body">
		
		<div class="body-inner">
			
			

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >2.2 启动 & 打包</a>
    </h1>
</div>




			<div class="page-wrapper" tabindex="-1" role="main">
				<div class="page-inner">
					
<div id="book-search-results">
    <div class="search-noresults">
    
					<section class="normal markdown-section">
						
						<h1 id="&#x542F;&#x52A8;--&#x6253;&#x5305;">&#x542F;&#x52A8; &amp; &#x6253;&#x5305;</h1>
<h2 id="1-&#x7A0B;&#x5E8F;&#x5165;&#x53E3;&#x6587;&#x4EF6;">1. &#x7A0B;&#x5E8F;&#x5165;&#x53E3;&#x6587;&#x4EF6;</h2>
<p><strong><em>server/main.go</em></strong> &#x662F;&#x6574;&#x4E2A;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x7684;&#x5165;&#x53E3;&#x6587;&#x4EF6;</p>
<p><strong><em>&#x542F;&#x52A8;&#x548C;&#x6253;&#x5305;&#x6307;&#x4EE4;&#x5FC5;&#x987B;&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x5185;&#x6267;&#x884C;</em></strong></p>
<h2 id="2-go-&#x6307;&#x4EE4;">2. go &#x6307;&#x4EE4;</h2>
<pre><code class="lang-shell">go run server/main.go
</code></pre>
<pre><code class="lang-shell">go build server/main.go
</code></pre>
<h2 id="3-make-&#x6307;&#x4EE4;">3. make &#x6307;&#x4EE4;</h2>
<p>make&#x6307;&#x4EE4;&#x8981;&#x6C42;&#x5148;&#x5728;&#x7CFB;&#x7EDF;&#x4E2D;&#x5B89;&#x88C5;&#x5DE5;&#x5177;&#x5305;&#xFF0C;ubuntu&#x7CFB;&#x7EDF;&#x5B89;&#x88C5;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-shell">apt-get install -y make
</code></pre>
<p>&#x5728;&#x521B;&#x5EFA;&#x9879;&#x76EE;&#x65F6; <strong>Makefile</strong> &#x5DF2;&#x7ECF;&#x9ED8;&#x8BA4;&#x5728;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x4E2D;&#x521B;&#x5EFA;&#xFF0C;&#x5177;&#x4F53;&#x5185;&#x5BB9;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>build:
    go build -o bin/example server/main.go

run:
    go run server/main.go

push:
    git add .
    git commit -m &quot;update&quot;
    git push
</code></pre><p>&#x5176;&#x4E2D;&#x5305;&#x542B;&#x4E86; <strong>make build</strong>, <strong>make run</strong>, <strong>make push</strong> &#x4E09;&#x4E2A;&#x6307;&#x4EE4;&#xFF0C;&#x82E5;&#x6709;&#x9700;&#x8981;&#x53EF;&#x81EA;&#x5B9A;&#x4E49;&#x6307;&#x4EE4;</p>
<ul>
<li><strong>make build</strong>: &#x6253;&#x5305;&#x7A0B;&#x5E8F;&#xFF0C;&#x6253;&#x5305;&#x540E;&#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x4F4D;&#x4E8E; <strong>bin</strong> &#x76EE;&#x5F55;&#x4E2D;</li>
<li><strong>make run</strong>: &#x76F4;&#x63A5;&#x8FD0;&#x884C;&#x7A0B;&#x5E8F;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x4F7F;&#x7528;&#x4E86; <strong>go run</strong> &#x6307;&#x4EE4;&#x542F;&#x52A8;</li>
<li><strong>make push</strong>: &#x63A8;&#x9001;&#x4EE3;&#x7801;&#xFF0C;&#x5F53;&#x9700;&#x8981;&#x63D0;&#x4EA4;&#x4EE3;&#x7801;&#x65F6;&#xFF0C;&#x82E5;&#x4E0D;&#x9700;&#x8981;&#x4FEE;&#x6539;&#x63D0;&#x4EA4;&#x8BF4;&#x660E;&#xFF0C;&#x53EF;&#x6267;&#x884C;&#x6307;&#x4EE4;&#x5B8C;&#x6210; git &#x64CD;&#x4F5C;</li>
</ul>
<h2 id="4-csingo-&#x6307;&#x4EE4;">4. csingo &#x6307;&#x4EE4;</h2>
<p>csingo &#x6846;&#x67B6;&#x5C01;&#x88C5;&#x4E86;&#x542F;&#x52A8;&#x7A0B;&#x5E8F;&#x7684;&#x6307;&#x4EE4;&#xFF0C;&#x53EF;&#x4F7F;&#x7528;&#x5DE5;&#x5177;&#x547D;&#x4EE4;&#x542F;&#x52A8;&#x7A0B;&#x5E8F;&#x3002;&#x5176;&#x539F;&#x7406;&#x662F;&#x5728;&#x5DE5;&#x5177;&#x4E2D;&#x8C03;&#x7528;&#x7CFB;&#x7EDF;shell&#xFF0C;&#x6267;&#x884C; go &#x76F8;&#x5173;&#x6307;&#x4EE4;&#x3002;</p>
<p>csingo &#x542F;&#x52A8;&#x7A0B;&#x5E8F;&#x5305;&#x542B;&#x4E86;&#x4E24;&#x79CD;&#x6A21;&#x5F0F;&#xFF1A;<strong><em>&#x76F4;&#x63A5;&#x542F;&#x52A8;</em></strong>&#xFF0C;<strong><em>&#x70ED;&#x542F;&#x52A8;</em></strong></p>
<h3 id="41-&#x76F4;&#x63A5;&#x542F;&#x52A8;">4.1 &#x76F4;&#x63A5;&#x542F;&#x52A8;</h3>
<p>&#x5B9E;&#x9645;&#x4E0A;&#x4F7F;&#x7528;&#x4E86; <strong>go run</strong> &#x6307;&#x4EE4;&#x542F;&#x52A8;</p>
<pre><code class="lang-shell">csingo server::start
</code></pre>
<h3 id="42-&#x70ED;&#x542F;&#x52A8;">4.2 &#x70ED;&#x542F;&#x52A8;</h3>
<p>&#x5728;&#x521B;&#x5EFA;&#x9879;&#x76EE;&#x65F6;&#xFF0C;&#x9879;&#x76EE;&#x6839;&#x76EE;&#x5F55;&#x4E2D;&#x5305;&#x542B;&#x4E86; <strong>.watch</strong> &#x6587;&#x4EF6;&#xFF0C;&#x8BE5;&#x6587;&#x4EF6;&#x5B9A;&#x4E49;&#x4E86;&#x9700;&#x8981;&#x76D1;&#x542C;&#x7684;&#x76EE;&#x5F55;&#x548C;&#x6587;&#x4EF6;&#xFF0C;&#x5F53;&#x8FD9;&#x4E9B;&#x6587;&#x4EF6;&#x53D1;&#x751F;&#x5185;&#x5BB9;&#x53D8;&#x52A8;&#xFF0C;&#x4F1A;&#x89E6;&#x53D1;&#x5DE5;&#x5177;&#x7EC8;&#x6B62;&#x7A0B;&#x5E8F;&#x8FD0;&#x884C;&#xFF0C;&#x5E76;&#x91CD;&#x65B0;&#x542F;&#x52A8;&#x7A0B;&#x5E8F;</p>
<pre><code class="lang-shell">csingo server::watch
</code></pre>

<script>console.log("plugin-popup....");document.onclick = function(e){ e.target.tagName === "IMG" && window.open(e.target.src,e.target.src)}</script><style>img{cursor:pointer}</style>
						
					</section>
					
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

				</div>
			</div>
			
		</div>

		
		
		<a href="2.1 安装.html" class="navigation navigation-prev " aria-label="Previous page: 2.1 安装">
			<i class="fa fa-angle-left"></i>
		</a>
		
		
		<a href="2.3 配置.html" class="navigation navigation-next " aria-label="Next page: 2.3 配置">
			<i class="fa fa-angle-right"></i>
		</a>
		
		
		
	</div>
	<script>
		var gitbook = gitbook || [];
		gitbook.push(function() {
			gitbook.page.hasChanged({"page":{"title":"2.2 启动 & 打包","level":"1.3.2","depth":2,"next":{"title":"2.3 配置","level":"1.3.3","depth":2,"path":"csingo/2 快速入门/2.3 配置.md","ref":"csingo/2 快速入门/2.3 配置.md","articles":[]},"previous":{"title":"2.1 安装","level":"1.3.1","depth":2,"path":"csingo/2 快速入门/2.1 安装.md","ref":"csingo/2 快速入门/2.1 安装.md","articles":[]},"dir":"ltr"},"config":{"plugins":["theme-fexa","-lunr","-search","search-pro","splitter","code","copy-code-button","expandable-chapters","expandable-chapters-small","accordion","yahei","popup"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"yahei":{},"summary":{"excludeDir":["img","styles"]},"splitter":{},"search-pro":{},"accordion":{},"popup":{},"theme-fexa":{"logo":"/logo.png"},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"fontSettings":{"family":"msyh","size":2},"highlight":{},"anchor-navigation-ex":{"showLevel":false},"expandable-chapters-small":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"Joe Chan","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"文档中心","language":"zh-hans","gitbook":">=2.0.0"},"file":{"path":"csingo/2 快速入门/2.2 启动 & 打包.md","mtime":"2023-12-13T02:52:56.565Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2024-07-05T10:23:53.810Z"},"basePath":"../..","book":{"language":""}});
		});
	</script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-accordion/accordionSelector.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-fexa/fexa.js"></script>
        
    

    </body>
</html>

